import logging
import time

import pytest


class Test:

    @pytest.mark.parametrize('setup_teardown', [None], indirect=True)
    def test(self, setup_teardown, device):
        logging.info('步骤1、长按桌面空白处，点击添加空白页')
        device.long_click(360, 640)
        device.refresh_layout()
        add_page = device.get_element_by_text('添加空白页')
        device.click_element(add_page)
        logging.info('预期结果1、可新增一个空白桌面，且可以左右滑动，桌面无异常')
        device.refresh_layout()
        icons = device.get_elements_by_type('Badge')
        assert len(icons) < 6, '当前页面图标数量为{}'.format(len(icons))

        logging.info('步骤2、在空白页长按桌面，点击删除空白页')
        device.long_click(360, 640)
        device.refresh_layout()
        del_page = device.get_element_by_text('删除空白页')
        device.click_element(del_page)
        logging.info('预期结果2、空白页被删除，桌面无异常')
        device.refresh_layout()
        icons = device.get_elements_by_type('Badge')
        assert len(icons) > 6, '当前页面图标数量为{}'.format(len(icons))
